package com.jswdwsx.ddns.schedule;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

/**
 * 程序启动时会先执行一次
 */
@Component
public class DoTaskAtStartup implements ApplicationRunner {
    final
    DDNSScheduledTask ddnsScheduledTask;

    public DoTaskAtStartup(DDNSScheduledTask ddnsScheduledTask) {
        this.ddnsScheduledTask = ddnsScheduledTask;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("Set once at startup");
        ddnsScheduledTask.checkAndUpdateRecord();
    }
}